import base64
import socket
#服务器端

from Cryptodome.Cipher import DES

#客户端

path = input("请输入存储路径：")
name = input("请输入文件名称：")
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('127.0.0.1',8001))
s.listen(3)
conn, addres=s.accept()
key = conn.recv(1024*1024)
key = base64.b64decode(key)
print(key)
des = DES.new(key, DES.MODE_ECB)  # 创建一个DES实例
data=conn.recv(1024*1024)
data=des.decrypt(data).rstrip()
data=base64.b64decode(data)
print("解密后的"+str(data))
conn.sendall(("服务器已接收到内容"+str(data)).encode())
flie = open(path+"\\"+name, "wb")
flie.write(data)
flie.close()
s.close()
